import request from '@/utils/request'

export function listOutboundRequests(queryParams) {
  return request({
    url: '/scheduling/requests/outbound',
    method: 'get',
    params: queryParams
  });
}

export function listInboundRequests(queryParams) {
  return request({
    url: '/scheduling/requests/inbound',
    method: 'get',
    params: queryParams
  });
}

// 查询调度请求列表
export function listRequests(query) {
  return request({
    url: '/scheduling/requests/list',
    method: 'get',
    params: query
  })
}

// 查询调度请求详细
export function getRequests(id) {
  return request({
    url: '/scheduling/requests/' + id,
    method: 'get'
  })
}

// 新增调度请求
export function addRequests(data) {
  return request({
    url: '/scheduling/requests',
    method: 'post',
    data: data
  })
}

// 修改调度请求
export function updateRequests(data) {
  return request({
    url: '/scheduling/requests',
    method: 'put',
    data: data
  })
}

// 删除调度请求
export function delRequests(id) {
  return request({
    url: '/scheduling/requests/' + id,
    method: 'delete'
  })
}

// 获取单位列表
export function getDeptList() {
  return request({
    url: '/system/dept/listAll/allList',
    method: 'get'
  })
}

// 获取单位对应车辆列表
export function handleDeptChange(deptId) {
  return request({
    url: '/vehicles/vehicles/list/' + deptId,
    method: 'get'
  })
}

//拒绝该请求
export function rejectDispatchRequest(dispatchRequestsId, rejectionReason) {
  return request({
    url: '/scheduling/requests',
    method: 'put',
    data: {
      dispatchRequestsId,
      rejectionReason
    }
  })
}

// 取车
export function takeVehicle(dispatchRequestsId) {
  return request({
    url: '/scheduling/executions',
    method: 'post',
    data: {
      dispatchRequestsId
    }
  })
}

//还车
export function returnVehicle(id) {
  return request({
    url: '/scheduling/executions/' + id,
    method: 'delete',
  });
}

//查询调度请求详情
export function getDispatchDetails(id) {
  return request({
    url: '/scheduling/requests/' + id,
    method: 'get'
  })
}

//查询调度执行详情
export function getDispatchExecutionDetails(id) {
  return request({
    url: '/scheduling/executions/' + id,
    method: 'get'
  })
}